home *** CD-ROM | disk | FTP | other *** search
- property ppathFollower,pdestinationList,pcurrentDestination,pboundryPoint,pwhichBoundry,ppathFollowerRoads ,pleftDiff,prightDiff,ptopDiff, pbottomDiff,pmovementDiff
-
- on new me,pF,startDest,endDest
- set ppathFollower=pF --sprite# of object following the path
- set pdestinationList=[:] --list of points(sprites) of all destinations to be reached along the path
- set pcurrentDestination=1 --destination that currently has to be reached
- set ppathFollowerRoads=[] --list of all invisible shapes(rectangles) that are layed out along the path
- set pleftDiff=point(-5,0) --by how much an object has to move to the left,right,up, and down
- set prightDiff=point(5,0)
- set ptopDiff=point(0,-5)
- set pbottomDiff=point(0,5)
- initDestinations me,startDest,endDest
- return me
- end
-
-
- --creates the list of all points(sprites) of destination
- on initDestinations me,startDest,endDest
- repeat with i=startDest to endDest
- addProp(pdestinationList,the name of the member of sprite i,i)
- end repeat
- end
-
-
- --creates the list of all invisible shapes(sprites) along the path
- on initPath me,startRoad,endRoad
- repeat with i=startRoad to endRoad
- add(ppathFollowerRoads,i)
- end repeat
- end
-
-
- --called when a directional arrow is clicked. Turns an object to proper direction, sets corresponding movement differential(i.e. pleftDiff...),
- --and set the boundry point
- on setPathFollowerDirection me, directionMember
- puppetSprite ppathFollower,true
- set pboundryPoint=getPathBoundry(me,the name of directionMember)
- set prefix="p"
- set suffix="Diff"
- do "set pmovementDiff=value("&prefix&pwhichBoundry&suffix&")" --sets movement diff. based on direction
-
- set the member of sprite ppathFollower=member directionMember
- updateStage
- end
-
-
- --moves an object along the path till boundry or destination is encountered
- on movePathFollower me
- --checks if boundry point is reached
- if max(pmovementDiff) then --if positive difference (directions: right or down) ...
- if boundryIntoCoordinate(me, pwhichBoundry,ppathFollower) >= pboundryPoint then
- return(checkDestination(me))
- end if
- else
- if boundryIntoCoordinate(me, pwhichBoundry,ppathFollower) <= pboundryPoint then
- return(checkDestination(me))
- end if
- end if
-
- set the loc of sprite ppathFollower=the loc of sprite ppathFollower + pmovementDiff
- go to the frame
- return("")
- end
-
-
-
- --gets the boundry point based on direction(up:toppest boundry,down:lowest boundry,left:leftmost boundy,right:rightmost boundry)
- on getPathBoundry me,whichBoundry
- set pwhichBoundry=whichBoundry
- set roadBoundries=[]
- repeat with aRoad in ppathFollowerRoads
- if (sprite ppathFollower intersects aRoad) then
- add(roadBoundries,boundryIntoCoordinate(me, whichBoundry,aRoad))
- end if
- end repeat
- case (whichBoundry) of
- "right","bottom": return max(roadBoundries)
- "left","top": return min(roadBoundries)
- end case
- end
-
-
- --checks if any destination is reached, and returns frames to go to after a destination is reached
- on checkDestination me
- repeat with dest in pdestinationList
- set correctDest=getAt(pdestinationList,pcurrentDestination)
- if sprite ppathFollower intersects dest and dest=correctDest then --if correct dest. is reached ...
- -- puppetSprite ppathFollower,false
- set pcurrentDestination=pcurrentDestination+1
- return(getOne(pdestinationList,dest)&".correct")
- else if sprite ppathFollower intersects dest then --if wrong dest. is reached, return tractor back and play instructions again
- -- puppetSprite ppathFollower,false
- return(getOne(pdestinationList,dest)&".wrong")
- end if
- end repeat
- return("")
- end
-
-
- on boundryIntoCoordinate me, boundry,spr
- set coord=0
- do "set coord=the "&boundry&" of sprite "&spr
- return(coord)
- end
-
-
- on getDestinationName me
- set dest=getAt(pdestinationList,pcurrentDestination)
- return(getOne(pdestinationList,dest))
- end
-